package com.lanmaoly.cunzheng.threadpoolfour;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 *
 * @author Administrator
 * @version 2017-10-18 14:46:59
 */
public class FixedThreadPoolTest {

	public static void main(String[] args) {
		Executor threadPool = Executors.newFixedThreadPool(3);
		for (int i = 0; i < 10; i++) {
			final int index = i;
			threadPool.execute(new Runnable() {

				@Override
				public void run() {
					try {
						System.out.println(index);
						Thread.sleep(2000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			});
		}
	}

}
